package com.kate.mall.order.price;

import com.kate.mall.order.dto.OrderItemDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @Description: 总金额默认计算器
 * @Auther: 新梦想*陈超
 * @Date: 2021/10/30 19:35
 */
@Component
@Slf4j
public class DefaultTotalPriceCalculator implements TotalPriceCalculator {
	
	/**
	 * 计算商品的总金额
	 */
	@Override
	public BigDecimal calculate(OrderItemDTO item) {
		BigDecimal totalPrice = item.getPrice().multiply(new BigDecimal(item.getNumber()));
		log.info("====默认的订单总价计算器，计算订单总价为：{}===="+totalPrice);
		return totalPrice;
	}
	
}